﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.IO;

namespace girapong
{

    public static class ScoresList
    {
        private const String SCORES = "ScoresList";
        public static void createIfNotExists()
        {
            if (!IsolatedStorageSettings.ApplicationSettings.Contains(SCORES))
            {
                List<score> scores = new List<score>();
                setScores(scores);
            }
        }
        public static void newScore(String score, String date, String type)
        {
            createIfNotExists();
            score nuevaPuntuacion = new score(score.ToString(), date, type);
            List<score> puntuaciones = (List<score>)IsolatedStorageSettings.ApplicationSettings[SCORES];
            puntuaciones.Add(nuevaPuntuacion);
            setScores(puntuaciones);
        }
        public static void removeScore(score p)
        {
            createIfNotExists();
            List<score> scores = (List<score>)IsolatedStorageSettings.ApplicationSettings[SCORES];
            scores.Remove(p);
            setScores(scores);
        }
        public static void setScores(List<score> scores_)
        {
            IsolatedStorageSettings.ApplicationSettings.Remove(SCORES);
            IsolatedStorageSettings.ApplicationSettings.Add(SCORES, scores_);

            IsolatedStorageSettings.ApplicationSettings.Save();
        }
        public static List<score> getScores()
        {
            createIfNotExists();
            List<score> scores = (List<score>)IsolatedStorageSettings.ApplicationSettings[SCORES];
            return scores;
        }

    }
}
